package com.yulin.security_redis.service;

import com.yulin.security_redis.bean.Menu;
import com.yulin.security_redis.config.HrUtils;
import com.yulin.security_redis.mapper.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
@CacheConfig(cacheNames = "menus_cache")
public class MenuService {

    @Autowired
    private MenuMapper menuMapper;

    public List<Menu> getAllMenu(){

        return menuMapper.getAllMenu();
    }


    public List<Menu> getMenusByHrId() {
        return menuMapper.getMenusByHrId(HrUtils.getCurrentHr().getId());
    }
}
